package com.nwpu.server.learning.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.nwpu.server.common.response.PageUtils;
import com.nwpu.server.common.response.R;
import com.nwpu.server.learning.entity.PretrainEntity;
import com.nwpu.server.learning.service.PretrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.nwpu.server.learning.entity.AlgorithmEntity;
import com.nwpu.server.learning.service.AlgorithmService;



/**
 * 预训练数据文件
 *
 * @author YuXingZh
 * @email 617058979@qq.com
 * @date 2022-10-23 21:00:03
 */
@RestController
@RequestMapping("learning/pretrain")
public class PretrainController {
    @Autowired
    private PretrainService pretrainService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = pretrainService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        PretrainEntity pretrain = pretrainService.getById(id);

        return R.ok().put("pretrain", pretrain);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PretrainEntity pretrain){
		pretrainService.save(pretrain);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PretrainEntity pretrain){
		pretrainService.updateById(pretrain);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		pretrainService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
